current version 1.6 - 24th April 2025
version | date | comment |
---|---|---|
1.0 | 1/Oct/2008 | Original code |
1.1 | 4/Jan/2011 | Read table specifing an id |
1.2 | 8/Apr/2023 | comments reformatted to adhere FORD specs. |
1.3 | 17/Apr/2024 | new public function TablesGetIds |
1.4 | 30/Aug/2024 | routines to create a new table from scratch and populate it |
1.5 | 04/Sep/2024 | new subroutine TablesGetFloatByString |
1.6 | 24/Apr/2025 | LINELENGTH set to 500 to prevent stack overflow in lon tables |
license: GNU GPL http://www.gnu.org/licenses/
This file is part of
MOSAICO -- MOdular library for raSter bAsed hydrologIcal appliCatiOn.
Copyright (C) 2011 Giovanni Ravazzani
Language: Fortran 90.
Software Standards: "European Standards for Writing and
Documenting Exchangeable Fortran 90 Code".
Module for managing tables Tables are stored in plain text. One single file may contain more than one table. Example of a table:
Table Start
Title: Stage discharge relatioship. #inline comment
Id: Tab01 # mandatory
# This is a sample comment. You can put anything you want
# on comment lines. Comment lines can be put everywhere
Columns: [Stage] [Discharge] [Method]
Units: [m a.s.l.] [m3/s] [-]
300.0 10.0 measure
300.5 20.0 measure
301.0 50.0 measure
301.5 100.0 extrapolation
302.0 200.0 extrapolation
302.5 500.0 extrapolation
# another comment
Table End
Example program, reading tables from files:
PROGRAM TestTableLib
USE TableLib
USE DataTypeSizes
TYPE (TableCollection) :: tables
TYPE (Table) :: tab, tab2
REAL (KIND = float) :: out
REAL (KIND = double) :: dOut
INTEGER :: i
!initialize a new table reading from the file passed as an argument.
!At the end of initialization, file is closed.
CALL TableNew ( 'table.txt', tab )
!initialize a new table reading from a file already open.
!Unit of the file is passed as an argument.
!At the end of initialization, file is not closed.
OPEN (unit=10, file='table2.txt')
CALL TableNew ( 10, tab2 ) .
!initialize a collection of tables reading from a file whose name
!is specified as argument.
CALL TableNew ( 'tables.txt', tables )
!extract value from table with different methods.
!input value is a float number. Output can be long integer,
!float real or double real.
!get float that corresponds exactly to input float. Bound is not
!necessary (it does not make sense).
!If input value is not found, an error message is logged.
CALL TableGetValue ( 302., tab, 'stage', 'discharge', 'exact', out)
WRITE(*,*) 'The discharge corresponding to selected case is: ', out
!get float calculating a linear interpolation between the two nearest values.
!Option bound = 'fixed' limits the search inside the extreme values
!of the table. If extreme values are exceeded, an error is thrown.
CALL TableGetValue ( 302.4, tab, 'stage', 'discharge', 'linear', out, &
bound = 'fixed' )
WRITE(*,*) 'The discharge corresponding to input value is: ', out
!get float calculating a linear interpolation between the two nearest values.
!Option bound = 'extendlinear' means that if the input value is outside
!extreme values of the table, they are linearly extended using the
!last two elements of the table. A warning message is logged.
CALL TableGetValue ( 304., tab, 'stage', 'discharge', 'linear', out, &
bound = 'extendlinear' )
WRITE(*,*) 'The discharge corresponding to input value is: ', out
!get float calculating a linear interpolation between the two nearest values.
!Option bound = 'extendconstant' means that if the input value is
!outside extreme values of the table, the last element is extended
!as a constant. A warning message is logged.
CALL TableGetValue ( 304., tab, 'stage', 'discharge', 'linear', out, &
bound = 'extendconstant' )
WRITE(*,*) 'The discharge corresponding to input value is: ', out
!get float searching for the nearest value.
CALL TableGetValue ( 302.55, tab, 'stage', 'discharge', 'nearest', out)
WRITE(*,*) 'The discharge nearest to input value is: ', out
!get double calculating a linear interpolation between the two nearest values.
!Option bound = 'fixed' limits the search inside the extreme values of the
!table. If extreme values are exceeded, an error is thrown.
CALL TableGetValue ( 302.4, tab, 'stage', 'discharge', 'linear', dOut, &
bound = 'fixed' )
WRITE(*,*) 'The discharge corresponding to input value is: ', dOut
!get float calculating a linear interpolation between the two nearest values.
!Option bound = 'fixed' limits the search inside the extreme values of
!the table. If extreme values are exceeded, an error is thrown.
CALL TableGetValue ( 302.4, tables, 'tab02', 'stage', 'discharge', 'linear', &
out, bound = 'fixed' )
WRITE(*,*) 'The discharge corresponding to input value is: ', out
!get double calculating a linear interpolation between the two nearest values.
! Option bound = 'fixed' limits the search inside the extreme values of the table.
!If extreme values are exceeded, an error is thrown.
CALL TableGetValue ( 302.4, tables, 'tab02', 'stage', 'discharge', 'linear', &
dOut, bound = 'fixed' )
WRITE(*,*) 'The discharge corresponding to input value is: ', dOut
!export table on file. Name of the file is passed as argument
CALL TableExport ( tab, 'fileout.txt' )
!export table on a file taht is already open. Unit of file is passed as argument
OPEN (UNIT = 20, file = 'exported_table.txt')
CALL TableExport ( tab, 20 )
CLOSE (20)
!export a collection of tables on a file. Name of the file is passed as argument
CALL TableExport ( tables, 'table_collections.txt' )
!export just one table from a collection of tables on a filetaht is already open.
!Unit of file is passed as argument
OPEN (UNIT = 20, file = 'tab02.txt')
CALL TableExport ( tables, 20, 'tab02' )
CLOSE (20)
END PROGRAM TestTableLib
Example program, creating table from scratch:
PROGRAM CreateTableFromScratch
USE TableLib
USE DataTypeSizes
TYPE (Table) :: tab
CHARACTER (LEN = 300) :: string
CHARACTER (LEN = 100) :: row (3)
!create new table
CALL TableNew ( tab )
!set table id
string = 'table id'
CALL TableSetId ( tab, string)
!set table title
string = 'table title'
CALL TableSetTitle ( tab, string)
!Allocate variables
CALL TableSetRowCol ( tab, 2, 3 )
!set column header and unit
CALL TableSetColHeader (tab, 1, 'id')
CALL TableSetColHeader (tab, 2, 'Qin')
CALL TableSetColHeader (tab, 3, 'Qout')
CALL TableSetColUnit (tab, 1, '-')
CALL TableSetColUnit (tab, 2, 'm3/s')
CALL TableSetColUnit (tab, 3, 'm3/s')
!fill in the first row
row = (/ '1', '3.5', '2.0' /)
CALL TableFillRow (tab, 1, row)
!fill in the second row
row = (/ '2', '13.5', '15.4' /)
CALL TableFillRow (tab, 2, row)
END PROGRAM CreateTableFromScratch
References and Credits: ODT data table format http://math.nist.gov/oommf/doc/userguide11b2/userguide/Data_table_format_ODT.html
Known issues: when processing table with lots of rows, stack overflow may occur. Decrease LINELENGTH parameter or increase stack size before compiling.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer(kind=long), | private, | parameter | :: | LINELENGTH | = | 500 |
write a table on file.
Arguments:
tab
table to export
file
file to whom write the table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Table), | intent(in) | :: | tab | |||
character(len=*), | intent(in) | :: | file | |||
logical, | intent(in), | optional | :: | append |
write a table on file taht is already open.
Arguments:
tab
table to export
iunit
unit of file to whom write the table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Table), | intent(in) | :: | tab | |||
integer(kind=short), | intent(in) | :: | iunit |
write a collection of tables on file. If id is present, only the table
corresponding to that id is written.
Arguments:
tables
collection of tables to be exported
file
file to whom write the table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(TableCollection), | intent(in) | :: | tables | |||
character(len=*), | intent(in) | :: | file | |||
character(len=*), | intent(in), | optional | :: | id |
write a collection of tables on file already open. If id is present,
only the table corresponding to that id is written.
Arguments:
tables
collection of tables to be exported
iunit
unit to whom write the table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(TableCollection), | intent(in) | :: | tables | |||
integer(kind=short), | intent(in) | :: | iunit | |||
character(len=*), | intent(in), | optional | :: | id |
return the number of rows in a table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Table), | intent(in) | :: | tab |
return the number of rows of a table in a table collection
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(TableCollection), | intent(in) | :: | tables | |||
character(len=*), | intent(in) | :: | id |
returns a float from column defined by keyOut corresponding to valueIn
contained in column defined by keyIn.
Arguments:
valueIn
input value
tab
table to search in
keyIn
defines header of the column of the input value
keyOut
defines header of the column of the output value
match
method to match input value. Possible values are:
'exact' = column must contain exact input value
'linear' = calculates linear interpolation between two
bounding values
'nearest' = search for the nearest value in input column
bound
method to manage bounds. Possible values are:
'fixed' = extreme values are treated as a wall
'extendlinear' = extend bounds with linear interpolation
of last two extreme values
'extendconstant' = extend bounds preserving extreme value constant
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=float), | intent(in) | :: | valueIn | |||
type(Table), | intent(in) | :: | tab | |||
character(len=*), | intent(in) | :: | keyIn | |||
character(len=*), | intent(in) | :: | keyOut | |||
character(len=*), | intent(in) | :: | match | |||
real(kind=float), | intent(out) | :: | valueOut | |||
character(len=*), | intent(in), | optional | :: | bound |
returns a float from column defined by keyOut corresponding to
valueIn (string) contained in column defined by keyIn.
Arguments:
valueIn
input value
tab
table to search in
keyIn
defines header of the column of the input value
keyOut
defines header of the column of the output value
The method to match input value is 'exact' by definition, no need to include optional arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | valueIn | |||
type(Table), | intent(in) | :: | tab | |||
character(len=*), | intent(in) | :: | keyIn | |||
character(len=*), | intent(in) | :: | keyOut | |||
real(kind=float), | intent(out) | :: | valueOut |
returns a float from column defined by keyOut corresponding to valueIn
(string) contained in column defined by keyIn. Table is identified by its id.
Arguments:
valueIn
input value
tables
collection of tables to search in
id
id of the table to search in
keyIn
defines header of the column of the input value
keyOut
defines header of the column of the output value
The method to match input value is 'exact' by definition, no need to include optional arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | valueIn | |||
type(TableCollection), | intent(in) | :: | tables | |||
character(len=*), | intent(in) | :: | id | |||
character(len=*), | intent(in) | :: | keyIn | |||
character(len=*), | intent(in) | :: | keyOut | |||
real(kind=float), | intent(out) | :: | valueOut |
returns a double from column defined by keyOut corresponding to valueIn
contained in column defined by keyIn.
Arguments:
valueIn
input value
tab
table to search in
keyIn
defines header of the column of the input value
keyOut
defines header of the column of the output value
match
method to match input value. Possible values are:
'exact' = column must contain exact input value
'linear' = calculates linear interpolation between two
bounding values
'nearest' = search for the nearest value in input column
bound
method to manage bounds. Possible values are:
'fixed' = extreme values are treated as a wall
'extendlinear' = extend bounds with linear interpolation
of last two extreme values
'extendconstant' = extend bounds preserving extreme value constant
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=float), | intent(in) | :: | valueIn | |||
type(Table), | intent(in) | :: | tab | |||
character(len=*), | intent(in) | :: | keyIn | |||
character(len=*), | intent(in) | :: | keyOut | |||
character(len=*), | intent(in) | :: | match | |||
real(kind=double), | intent(out) | :: | valueOut | |||
character(len=*), | intent(in), | optional | :: | bound |
returns a string from column defined by keyOut corresponding to valueIn
contained in column defined by keyIn.
Arguments:
valueIn
input value
tab
table to search in
keyIn
defines header of the column of the input value
keyOut
defines header of the column of the output value
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=float), | intent(in) | :: | valueIn | |||
type(Table), | intent(in) | :: | tab | |||
character(len=*), | intent(in) | :: | keyIn | |||
character(len=*), | intent(in) | :: | keyOut | |||
character(len=*), | intent(out) | :: | valueOut |
returns a float from column defined by keyOut corresponding to valueIn
contained in column defined by keyIn. Table is identified by its id.
Arguments:
valueIn
input value
tables
collection of tables to search in
id
id of the table to search in
keyIn
defines header of the column of the input value
keyOut
defines header of the column of the output value
match
method to match input value. Possible values are:
'exact' = column must contain exact input value
'linear' = calculates linear interpolation between two
bounding values
'nearest' = search for the nearest value in input column
bound
method to manage bounds. Possible values are:
'fixed' = extreme values are treated as a wall
'extendlinear' = extend bounds with linear interpolation
of last two extreme values
'extendconstant' = extend bounds preserving extreme value constant
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=float), | intent(in) | :: | valueIn | |||
type(TableCollection), | intent(in) | :: | tables | |||
character(len=*), | intent(in) | :: | id | |||
character(len=*), | intent(in) | :: | keyIn | |||
character(len=*), | intent(in) | :: | keyOut | |||
character(len=*), | intent(in) | :: | match | |||
real(kind=float), | intent(out) | :: | valueOut | |||
character(len=*), | intent(in), | optional | :: | bound |
returns a double from column defined by keyOut corresponding to valueIn
contained in column defined by keyIn. Table is identified by its id.
Arguments:
valueIn
input value
tables
collection of tables to search in
id
id of the table to search in
keyIn
defines header of the column of the input value
keyOut
defines header of the column of the output value
match
method to match input value. Possible values are:
'exact' = column must contain exact input value
'linear' = calculates linear interpolation between two
bounding values
'nearest' = search for the nearest value in input column
bound
method to manage bounds. Possible values are:
'fixed' = extreme values are treated as a wall
'extendlinear' = extend bounds with linear interpolation
of last two extreme values
'extendconstant' = extend bounds preserving extreme value constant
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=float), | intent(in) | :: | valueIn | |||
type(TableCollection), | intent(in) | :: | tables | |||
character(len=*), | intent(in) | :: | id | |||
character(len=*), | intent(in) | :: | keyIn | |||
character(len=*), | intent(in) | :: | keyOut | |||
character(len=*), | intent(in) | :: | match | |||
real(kind=double), | intent(out) | :: | valueOut | |||
character(len=*), | intent(in), | optional | :: | bound |
returns a string from column defined by keyOut corresponding to valueIn
contained in column defined by keyIn. Table is identified by its id.
Arguments:
valueIn
input value
tables
collection of tables to search in
id
id of the table to search in
keyIn
defines header of the column of the input value
keyOut
defines header of the column of the output value
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=float), | intent(in) | :: | valueIn | |||
type(TableCollection), | intent(in) | :: | tables | |||
character(len=*), | intent(in) | :: | id | |||
character(len=*), | intent(in) | :: | keyIn | |||
character(len=*), | intent(in) | :: | keyOut | |||
character(len=*), | intent(out) | :: | valueOut |
read a collection of tables from specified file.
Arguments:
file
file in which table is contained
tables
returned collection of tables
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | file | |||
type(TableCollection), | intent(out) | :: | tables |
read a collection of tables from specified unit. File is already open.
Arguments:
unit
unit of file in which table is contained
tables
returned collection of tables
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=short), | intent(in) | :: | unit | |||
type(TableCollection), | intent(out) | :: | tables |
read a table from specified file. File is not yet open.
If id is not specified, in a file containing multiple tables,
the first table is read
Arguments:
file
file in which table is contained
tab
returned table
id
optional, id of table to read
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | file | |||
type(Table), | intent(out) | :: | tab | |||
character(len=*), | intent(in), | optional | :: | id |
read a table from specified file unit. File is already open.
Arguments:
unit
file in which table is contained
tab
returned table
id
optional, id of table to read
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=short), | intent(in) | :: | unit | |||
type(Table), | intent(out) | :: | tab | |||
character(len=*), | intent(in), | optional | :: | id |
create a new table from scratch and initialize variables
Arguments:
tab
returned table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Table), | intent(out) | :: | tab |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(Column), | public, | POINTER | :: | col(:) | |||
character(len=30), | public | :: | id |
Max length of id: 30 characters |
|||
integer(kind=long), | public | :: | noCols |
number of columns |
|||
integer(kind=long), | public | :: | noRows |
number of rows |
|||
character(len=300), | public | :: | title |
Max length of title: 300 characters |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(Table), | public, | POINTER | :: | elem(:) | |||
integer(kind=long), | public | :: | number |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=100), | public | :: | header | ||||
character(len=100), | public, | POINTER | :: | row(:) | |||
character(len=100), | public | :: | unit |
Return a list of Ids from TableCollection
Arguments:
tables
collections of tbles
Result:
Return Ids
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(TableCollection), | intent(in) | :: | tables |
return the number of rows of a table in a table collection
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(TableCollection), | intent(in) | :: | tables | |||
character(len=*), | intent(in) | :: | id |
Count the number of columns in a table stored in a collection of lines.
Method:
count the number of tokens included in parentheses [].
Arguments:
lines
collections of lines
Result:
Return number of columns
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=LINELENGTH), | intent(in), | POINTER | :: | lines(:) |
Count the number of rowss in a table stored in a collection of lines.
Method:
count the number of non blank lines that have not a keyword.
Arguments:
lines
collections of lines
Result:
Return number of rows
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=LINELENGTH), | intent(in), | POINTER | :: | lines(:) |
search the file for beginning of next table defined by keyword Table Start
Arguments:
unit
file in which operate search
id
optional, table id
line
optional, line of file to begin search
Result:
Return -1 when table is not found
line of beginning of a table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=short), | intent(in) | :: | unit | |||
character(len=*), | intent(in), | optional | :: | id | ||
integer(kind=long), | intent(inout), | optional | :: | line |
return the number of rows in a table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Table), | intent(in) | :: | tab |
Read the Id of the table. Id is mandatory and must be unique.
Arguments:
lines
collections of lines
Result:
Return Id
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=LINELENGTH), | intent(in), | POINTER | :: | lines(:) |
Read the title of the table. Title is optional.
Arguments:
lines
collections of lines
Result:
Return title if exists
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=LINELENGTH), | intent(in), | POINTER | :: | lines(:) |
returns the position of table in collection of tables identified by id.
Arguments:
tables
collection of tables to search in
id
id of the table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(TableCollection), | intent(in) | :: | tables | |||
character(len=*), | intent(in) | :: | id |
set row content
Arguments:
tab
returned table
row
column to be changed
content
string array to fill in row
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Table), | intent(inout) | :: | tab | |||
integer(kind=short), | intent(in) | :: | row | |||
character(len=*), | intent(in) | :: | content(:) |
set header of a specified column
Arguments:
tab
returned table
col
column to be changed
header
header string
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Table), | intent(inout) | :: | tab | |||
integer(kind=short), | intent(in) | :: | col | |||
character(len=*), | intent(in) | :: | header |
set unit of a specified column
Arguments:
tab
returned table
col
column to be changed
unit
unit string
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Table), | intent(inout) | :: | tab | |||
integer(kind=short), | intent(in) | :: | col | |||
character(len=*), | intent(in) | :: | unit |
set table id
Arguments:
tab
returned table
id
table id
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Table), | intent(inout) | :: | tab | |||
character(len=*), | intent(in) | :: | id |
set number of rows and columns and allocate variables
Arguments:
tab
returned table
nrow
number of rows
ncol
number of columns
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Table), | intent(inout) | :: | tab | |||
integer(kind=short), | intent(in) | :: | nrow | |||
integer(kind=short), | intent(in) | :: | ncol |
set table title
Arguments:
tab
returned table
title
table title
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Table), | intent(inout) | :: | tab | |||
character(len=*), | intent(in) | :: | title |
returns a float from column defined by keyOut corresponding to valueIn
(string) contained in column defined by keyIn. Table is identified by its id.
Arguments:
valueIn
input value
tables
collection of tables to search in
id
id of the table to search in
keyIn
defines header of the column of the input value
keyOut
defines header of the column of the output value
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | valueIn | |||
type(TableCollection), | intent(in) | :: | tables | |||
character(len=*), | intent(in) | :: | id | |||
character(len=*), | intent(in) | :: | keyIn | |||
character(len=*), | intent(in) | :: | keyOut | |||
real(kind=float), | intent(out) | :: | valueOut |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(TableCollection), | intent(in) | :: | tables | |||
integer(kind=long), | intent(in) | :: | pos |
create a new table from scratch and initialize variables
Arguments:
tab
returned table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Table), | intent(out) | :: | tab |
returns a double from column defined by keyOut corresponding to valueIn
contained in column defined by keyIn.
Arguments:
valueIn
input value
tab
table to search in
keyIn
defines header of the column of the input value
keyOut
defines header of the column of the output value
match
method to match input value. Possible values are:
'exact' = column must contain exact input value
'linear' = calculates linear interpolation between two
bounding values
'nearest' = search for the nearest value in input column
bound
method to manage bounds. Possible values are:
'fixed' = extreme values are treated as a wall
'extendlinear' = extend bounds with linear interpolation
of last two extreme values
'extendconstant' = extend bounds preserving extreme value constant
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=float), | intent(in) | :: | valueIn | |||
type(Table), | intent(in) | :: | tab | |||
character(len=*), | intent(in) | :: | keyIn | |||
character(len=*), | intent(in) | :: | keyOut | |||
character(len=*), | intent(in) | :: | match | |||
real(kind=double), | intent(out) | :: | valueOut | |||
character(len=*), | intent(in), | optional | :: | bound |
returns a float from column defined by keyOut corresponding to valueIn
contained in column defined by keyIn.
Arguments:
valueIn
input value
tab
table to search in
keyIn
defines header of the column of the input value
keyOut
defines header of the column of the output value
match
method to match input value. Possible values are:
'exact' = column must contain exact input value
'linear' = calculates linear interpolation between two
bounding values
'nearest' = search for the nearest value in input column
bound
method to manage bounds. Possible values are:
'fixed' = extreme values are treated as a wall
'extendlinear' = extend bounds with linear interpolation
of last two extreme values
'extendconstant' = extend bounds preserving extreme value constant
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=float), | intent(in) | :: | valueIn | |||
type(Table), | intent(in) | :: | tab | |||
character(len=*), | intent(in) | :: | keyIn | |||
character(len=*), | intent(in) | :: | keyOut | |||
character(len=*), | intent(in) | :: | match | |||
real(kind=float), | intent(out) | :: | valueOut | |||
character(len=*), | intent(in), | optional | :: | bound |
returns a float from column defined by keyOut corresponding to
valueIn (string) contained in column defined by keyIn.
Arguments:
valueIn
input value
tab
table to search in
keyIn
defines header of the column of the input value
keyOut
defines header of the column of the output value
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | valueIn | |||
type(Table), | intent(in) | :: | tab | |||
character(len=*), | intent(in) | :: | keyIn | |||
character(len=*), | intent(in) | :: | keyOut | |||
real(kind=float), | intent(out) | :: | valueOut |
read a table from specified file. File is not yet open.
If id is not specified, in a file containing multiple tables,
the first table is read
Arguments:
file
file in which table is contained
tab
returned table
id
optional, id of table to read
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | file | |||
type(Table), | intent(out) | :: | tab | |||
character(len=*), | intent(in), | optional | :: | id |
read a table from specified file unit. File is already open.
Arguments:
unit
file in which table is contained
tab
returned table
id
optional, id of table to read
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=short), | intent(in) | :: | unit | |||
type(Table), | intent(out) | :: | tab | |||
character(len=*), | intent(in), | optional | :: | id |
returns a string from column defined by keyOut corresponding to valueIn
contained in column defined by keyIn.
Arguments:
valueIn
input value
tab
table to search in
keyIn
defines header of the column of the input value
keyOut
defines header of the column of the output value
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=float), | intent(in) | :: | valueIn | |||
type(Table), | intent(in) | :: | tab | |||
character(len=*), | intent(in) | :: | keyIn | |||
character(len=*), | intent(in) | :: | keyOut | |||
character(len=*), | intent(out) | :: | valueOut |
read the content of the table.
Arguments:
lines
collection of strings that contain table information
tab
table to update
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=LINELENGTH), | intent(in), | POINTER | :: | lines(:) | ||
type(Table), | intent(out) | :: | tab |
read header of the columns of the table.
Arguments:
lines
collection of strings that contain table information
tab
table to update
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=LINELENGTH), | intent(in), | POINTER | :: | lines(:) | ||
type(Table), | intent(out) | :: | tab |
read unit of the columns of the table.
Arguments:
lines
collection of strings that contain table information
tab
table to update
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=LINELENGTH), | intent(in), | POINTER | :: | lines(:) | ||
type(Table), | intent(out) | :: | tab |
read the lines of a table which are stored in an array of strings.
Non significative lines (i.e. comments or blank lines) are ignored.
Subroutine supposes that the cursor is sync to the first line after
the keyword 'Table Start'. hence it is must benn called after
a call to tableFileSync.
Arguments:
unit
file in which table is contained
lines
returned collection of linestable
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=short), | intent(in) | :: | unit | |||
character(len=LINELENGTH), | intent(out), | POINTER | :: | lines(:) |
write a table on file.
Arguments:
tab
table to export
file
file to whom write the table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Table), | intent(in) | :: | tab | |||
character(len=*), | intent(in) | :: | file | |||
logical, | intent(in), | optional | :: | append |
write a table on file taht is already open.
Arguments:
tab
table to export
iunit
unit of file to whom write the table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Table), | intent(in) | :: | tab | |||
integer(kind=short), | intent(in) | :: | iunit |
returns a double from column defined by keyOut corresponding to valueIn
contained in column defined by keyIn. Table is identified by its id.
Arguments:
valueIn
input value
tables
collection of tables to search in
id
id of the table to search in
keyIn
defines header of the column of the input value
keyOut
defines header of the column of the output value
match
method to match input value. Possible values are:
'exact' = column must contain exact input value
'linear' = calculates linear interpolation between two
bounding values
'nearest' = search for the nearest value in input column
bound
method to manage bounds. Possible values are:
'fixed' = extreme values are treated as a wall
'extendlinear' = extend bounds with linear interpolation
of last two extreme values
'extendconstant' = extend bounds preserving extreme value constant
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=float), | intent(in) | :: | valueIn | |||
type(TableCollection), | intent(in) | :: | tables | |||
character(len=*), | intent(in) | :: | id | |||
character(len=*), | intent(in) | :: | keyIn | |||
character(len=*), | intent(in) | :: | keyOut | |||
character(len=*), | intent(in) | :: | match | |||
real(kind=double), | intent(out) | :: | valueOut | |||
character(len=*), | intent(in), | optional | :: | bound |
returns a float from column defined by keyOut corresponding to valueIn
contained in column defined by keyIn. Table is identified by its id.
Arguments:
valueIn
input value
tables
collection of tables to search in
id
id of the table to search in
keyIn
defines header of the column of the input value
keyOut
defines header of the column of the output value
match
method to match input value. Possible values are:
'exact' = column must contain exact input value
'linear' = calculates linear interpolation between two
bounding values
'nearest' = search for the nearest value in input column
bound
method to manage bounds. Possible values are:
'fixed' = extreme values are treated as a wall
'extendlinear' = extend bounds with linear interpolation
of last two extreme values
'extendconstant' = extend bounds preserving extreme value constant
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=float), | intent(in) | :: | valueIn | |||
type(TableCollection), | intent(in) | :: | tables | |||
character(len=*), | intent(in) | :: | id | |||
character(len=*), | intent(in) | :: | keyIn | |||
character(len=*), | intent(in) | :: | keyOut | |||
character(len=*), | intent(in) | :: | match | |||
real(kind=float), | intent(out) | :: | valueOut | |||
character(len=*), | intent(in), | optional | :: | bound |
read a collection of tables from specified file.
Arguments:
file
file in which table is contained
tables
returned collection of tables
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | file | |||
type(TableCollection), | intent(out) | :: | tables |
read a collection of tables from specified unit. File is already open.
Arguments:
unit
unit of file in which table is contained
tables
returned collection of tables
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=short), | intent(in) | :: | unit | |||
type(TableCollection), | intent(out) | :: | tables |
returns a string from column defined by keyOut corresponding to valueIn
contained in column defined by keyIn. Table is identified by its id.
Arguments:
valueIn
input value
tables
collection of tables to search in
id
id of the table to search in
keyIn
defines header of the column of the input value
keyOut
defines header of the column of the output value
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=float), | intent(in) | :: | valueIn | |||
type(TableCollection), | intent(in) | :: | tables | |||
character(len=*), | intent(in) | :: | id | |||
character(len=*), | intent(in) | :: | keyIn | |||
character(len=*), | intent(in) | :: | keyOut | |||
character(len=*), | intent(out) | :: | valueOut |
write a collection of tables on file. If id is present, only the table
corresponding to that id is written.
Arguments:
tables
collection of tables to be exported
file
file to whom write the table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(TableCollection), | intent(in) | :: | tables | |||
character(len=*), | intent(in) | :: | file | |||
character(len=*), | intent(in), | optional | :: | id |
write a collection of tables on file already open. If id is present,
only the table corresponding to that id is written.
Arguments:
tables
collection of tables to be exported
iunit
unit to whom write the table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(TableCollection), | intent(in) | :: | tables | |||
integer(kind=short), | intent(in) | :: | iunit | |||
character(len=*), | intent(in), | optional | :: | id |